# -*- coding: utf-8 -*-

import numpy as np

def gaussian_kernel(pt1, pt2, sigma):
    """计算任意两个样本的相似度
            Parameters
            ----------
            pt1 : vector
            pt2 : vector
                same dimension as pt1

            Return
            ----------
            dst : float
                the distance of two vectors that represents similarity
            """
    dst = np.exp(-1 * np.linalg.norm(pt1 - pt2) / sigma ** 2)
    return dst


def index_from_mat(i: int, j: int):
    """邻接矩阵的压缩存储，根据矩阵元素计算数组元素索引"""
    return i * (i+1) / 2 + j;